//
//  HLBottomView.m
//  HLMusicBox
//
//  Created by hulinhu on 2018/1/3.
//  Copyright © 2018年 hulinhu. All rights reserved.
//

#import "HLBottomView.h"

@implementation HLBottomView {
    
    UIImageView *preImagV;      // 上一曲
    UIImageView *nextImagV;     // 上一曲
    UIImageView *palyListImagV ; // 播放列表
 

}

- (instancetype)initWithFrame:(CGRect)frame
             playbtnClick:(btnClick)btnClick {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        float width = self.width;
        float height = self.height;
        
        float preImagVY = height/3;
        
        // 上一曲
        preImagV = [GFControl createImageViewWithFrame:CGRectMake(width/5.0, preImagVY, width*0.2, width*0.2) imageName:@"cm2_fm_btn_pre" cornerRadius:0 tapAction:^{
            !btnClick?:btnClick(MUSIC_PREONE);
        }];
        [self addSubview:preImagV];
        
        // 下一曲
        nextImagV = [GFControl createImageViewWithFrame:CGRectMake(width/5.0*3, preImagV.top, width/5.0, width/5.0) imageName:@"cm2_fm_btn_next" cornerRadius:0 tapAction:^{
            !btnClick?:btnClick(MUSIC_NEXTONE);
        }];
        [self addSubview:nextImagV];
        
        // 播放、暂停
        _playPause = [GFControl createImageViewWithFrame:CGRectMake(width/2.0-width*0.1, preImagV.top, width/5.0, width/5.0) imageName:@"cm2_fm_btn_pause" cornerRadius:0 tapAction:^{
            !btnClick?:btnClick(MUSIC_BEGPAUSE);
        }];
        [self addSubview:_playPause];
        
        // 循环模式
        _playMode = [GFControl createImageViewWithFrame:CGRectMake(0, preImagV.top , width/5.0, width/5.0) imageName:@"cm2_icn_loop" cornerRadius:0 tapAction:^{
            !btnClick?:btnClick(MUSIC_PLAYMODE);
        }];
        [self addSubview:_playMode];
        
        
        // 歌曲列表
        palyListImagV = [GFControl createImageViewWithFrame:CGRectMake(width/5.0 *4, preImagV.top, width/5.0, width/5.0) imageName:@"cm2_icn_list" cornerRadius:0 tapAction:^{
            !btnClick?:btnClick(MUSIC_PLAYLIST);
        }];
        [self addSubview:palyListImagV];
        
        float songSliderY = height / 5;
        
        // 播放进度条
        _songSlider = [[UISlider alloc] initWithFrame:CGRectMake(frame.size.width / 6,songSliderY, width * 2 / 3 , height* 0.2)];
        [_songSlider setThumbImage:[UIImage imageNamed:@"cm2_detail_knob_nomal"] forState:UIControlStateNormal];
        [_songSlider setThumbImage:[UIImage imageNamed:@"cm2_detail_knob_prs"] forState:UIControlStateHighlighted];
        _songSlider.tintColor = [UIColor whiteColor];
        [self addSubview:_songSlider];
        
        
        // 当前播放时间
        _currentTime = [GFControl createLabelWithFrame:CGRectMake(5, _songSlider.top, width/6-10, height*0.2) text:@"00:00" textAlignment:NSTextAlignmentCenter fontSize:15 textColor:[UIColor whiteColor]];
        [self addSubview:_currentTime];
        
        
        // 整歌时间
        _totalTime = [GFControl createLabelWithFrame:CGRectMake(width*5/6+5, _songSlider.top, width/6-10, height*0.2) text:@"00:00" textAlignment:NSTextAlignmentCenter fontSize:15 textColor:[UIColor whiteColor]];
        [self addSubview:_totalTime];
        
   
    }
    return self;
    
}

@end
